package com.ruoyi.resume.mapper;

import com.ruoyi.resume.domain.model.WorkExperiencePlus;
import com.ruoyi.resume.domain.model.resumeProfile.WorkExperience;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface WorkExperienceMapper {

    @Select("SELECT company_name, job_title, start_date, end_date, project_name, project_description, department " +
            "FROM work_experience WHERE resume_id = #{resumeId}")
    @Results({
            @Result(column = "company_name", property = "companyName"),
            @Result(column = "job_title", property = "jobTitle"),
            @Result(column = "start_date", property = "startTime"),
            @Result(column = "end_date", property = "endTime"),
            @Result(column = "project_name", property = "projectName"),
            @Result(column = "project_description", property = "projectDescription"),
            @Result(column = "department", property = "department")
    })
    List<WorkExperience> selectByResumeId(@Param("resumeId") int resumeId);

    @Delete("DELETE FROM work_experience WHERE resume_id = #{resumeId}")
    void deleteByResumeId(int resumeId);

    //查询所有简历的公司信息
    @Select("SELECT r.name,company_name, job_title, start_date, end_date, project_name, project_description, department " +
            "FROM work_experience join resume as r on work_experience.resume_id = r.id")
    @Results({
            @Result(column = "start_date", property = "startTime"),
            @Result(column = "end_date", property = "endTime")
    })
    List<WorkExperiencePlus> selectCompanyInfo();

    //获取工作经历对应的姓名
    @Select("SELECT name FROM resume WHERE id = #{resumeId}")
    String getNameByResumeId(@Param("resumeId") int resumeId);

}
